package cn.yr.controller;

import cn.yr.bean.User;
import cn.yr.mapper.UserMapper;
import cn.yr.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
public class UserController {

    @Resource
    private UserService userService;


    @RequestMapping("save")
    public String save(String data){

        ArrayList<User> users = new ArrayList<>();
        int d =100;
        for (int i = d; i < d+5; i++) {
            User user1 = new User();
            user1.setName("name"+i);
            users.add(user1);
        }

        userService.saveBatch(users);
        return  "ok";
    }
    @RequestMapping("get")
    public User getUser(long id){
        return userService.getById(id);
    }

    @RequestMapping("list")
    public List<User> list(){
        List<User> users = userService.list();
        return  users;
    }
}
